package com.example.zhaoping.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;


@Data
@AllArgsConstructor
@NoArgsConstructor
@Component
public class Result<T> {
    private int code;
    private String message;
    private T data;

    public Result  success(){
        return new Result(Constants.CODE_200,"操作成功",null);
    }
    public Result  success(String message){
        return new Result(Constants.CODE_200,message,null);
    }
    public Result  success(String msg, T data){
        return new Result(Constants.CODE_200,msg,data);
    }
    public Result  success(T data){
        return new Result(Constants.CODE_200,null,data);
    }
    public Result  error(Integer code,String msg){
        return new Result(code,msg,null);
    }
    public Result error(String msg){
        return new Result(Constants.CODE_400,msg,null);
    }
//    public boolean isSuccess(){
//        return this.getCode()!=Constants.CODE_200 ? false:true;
//    }
}
